#!/bin/bash
# runner

# A wrapper to run a given command. Will exec the given command upon a trigger.
# This is only to ensure we know the PID of the process in advance.
# (Leveraged by our ftrace scripts).
name=$(basename $0)

# Keep these vars in sync with the 'ping_ftrace.sh' script!
TRIGGER_FILE=/tmp/${name}
CPUMASK=2

if [ $# -eq 0 ]; then
  echo "usage: ${name} command"
  exit 1
fi

while [ ! -f ${TRIGGER_FILE} ]; do
  sleep .5
done
echo "> ${name}:$$: triggered"
# Exec the given command on CPU 1
exec taskset ${CPUMASK} "$@"
